//
//  ViewController.m
//  03-微博重做
//
//  Created by 俊怡商 on 15/4/27.
//  Copyright (c) 2015年 Kamael. All rights reserved.
//

#import "ViewController.h"
#import "JYStatusCell.h"
#import "JYStatus.h"

@interface ViewController ()
@property (nonatomic, strong) NSArray *statuses;

@end

@implementation ViewController
- (NSArray *)statuses{
    if (_statuses == nil) {
        _statuses = [JYStatus statusList];
    }
    return _statuses;
}
#pragma mark - tableView的数据源方法
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    JYStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.status = self.statuses[indexPath.row];
    return cell;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.statuses.count;
}
// 预估行高
-(CGFloat) tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 200;
}

// 计算精确行高
-(CGFloat ) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    JYStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
//    NSLog(@"%s",__func__);
//    return 150;
    return [cell rowHeightWithStatus:self.statuses[indexPath.row]];
}

@end
